# -- coding: utf-8 --
import cv2 as cv


src = cv.imread(r"F:\lena.jpg")
cv.imshow("Lena", src)
# gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY)  # 灰度化
# cv.imshow("gray", gray)

HSV = cv.cvtColor(src,cv.COLOR_BGR2HSV)  # HSV色域转换
cv.imshow("HSV", HSV)

b, g, r = cv.split(src)  # 分离BGR三通道
cv.imshow("B", b)
cv.imshow("G", g)
cv.imshow("R", r)

h, s, v = cv.split(HSV)  # 分离HSV三通道
cv.imshow("H", h)
cv.imshow("S", s)
cv.imshow("V", v)

# ret, binary = cv.threshold(gray, 120, 255, cv.THRESH_BINARY)  # 固定阈值二值化
# cv.imshow("binary", binary)

cv.waitKey(0)
